package com.qihang.web.controller;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qihang.common.Constants;
import com.qihang.common.PagerModel;
import com.qihang.core.domain.MenuEntity;
import com.qihang.core.service.MenuService;

/**
 * @author limn
 *
 */
@Controller
@RequestMapping("/menu")
public class MenuController {
	
	private Logger logger = Logger.getLogger(MenuController.class);
	
	@Resource(name = "menuService")
	private MenuService menuService;
	
	@RequestMapping("/menuList")
	public String menuList(MenuEntity paramMenu,ModelMap modelMap){
		PagerModel menuList = menuService.getMenuList(paramMenu);
		modelMap.put("pagerModel", menuList);
		return Constants.Sys.menuList;
	}
	
//	@ResponseBody
	@RequestMapping("/doMenuList")
	public String doMenuList(MenuEntity paramMenu,ModelMap modelMap){
		
		PagerModel menuList = menuService.getMenuList(paramMenu);
		System.err.println(menuList);
//		modelMap.put("Pager", menuList);
//		return Constants.Sys.menuList;
//		Map<String, Object> map = new HashMap<String, Object>();
		
		
//       map.put("Pager", menuList);
//		map.put("aaData", menuList.getResult());
//		map.put("iTotalRecords", menuList.getTotalResults());
//		return map;
		return Constants.Sys.menuList;
	}
	
	@RequestMapping("/addMenu")
	public String addMenu(MenuEntity paramMenu,ModelMap modelMap){
//		PagerModel menuList = menuService.getMenuList(paramMenu);
//		System.err.println(menuList);
//		modelMap.put("pagerModel", menuList);
//		modelMap.put("pager.offset", "4");
		return Constants.Sys.addMenu;
	}
	
}
